perm filename MUSIC.TVR[UP,DOC]7 blob sn#224712 filedate 1976-07-13 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00049 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00006 00002
C00007 00003	                            Music Manual
C00011 00004	                            Music Manual
C00014 00005	Music Manual
C00016 00006	Music Manual
C00019 00007	Music Manual                                             Declarations
C00023 00008	Music Manual                                             Declarations
C00027 00009	Music Manual                                             Declarations
C00030 00010	Music Manual
C00034 00011	Music Manual                                              Expressions
C00037 00012	Music Manual                                              Expressions
C00040 00013	Music Manual
C00044 00014	Music Manual                                               Statements
C00047 00015	Music Manual                                               Statements
C00050 00016	Music Manual                                               Statements
C00052 00017	Music Manual                                               Statements
C00056 00018	Music Manual
C00059 00019	Music Manual                                        Extended Commands
C00060 00020	Music Manual
C00063 00021	Music Manual                                          Unit Generators
C00066 00022	Music Manual                                          Unit Generators
C00069 00023	Music Manual                                          Unit Generators
C00072 00024	Music Manual                                          Unit Generators
C00075 00025	Music Manual
C00079 00026	Music Manual                                       Built-in Functions
C00082 00027	Music Manual                                       Built-in Functions
C00084 00028	Music Manual                                       Built-in Functions
C00086 00029	Music Manual
C00090 00030	Music Manual                                          Computing sound
C00095 00031	Music Manual                                          Computing sound
C00098 00032	Music Manual                                          Computing sound
C00100 00033	Music Manual
C00104 00034	Music Manual                                     Outputting the sound
C00108 00035	Music Manual
C00113 00036	Music Manual                                                   Syntax
C00115 00037	Music Manual
C00117 00038	Music Manual
C00120 00039	Music Manual                                          Error Messages.
C00123 00040	Music Manual                                          Error Messages.
C00125 00041	Music Manual                                          Error Messages.
C00127 00042	Music Manual                                          Error Messages.
C00130 00043	Music Manual                                          Error Messages.
C00132 00044	Music Manual                                          Error Messages.
C00134 00045	Music Manual
C00137 00046	Music Manual                                      Changes since MUS10
C00140 00047	                            Music Manual
C00145 00048	                            Music Manual
C00146 00049	
C00147 ENDMK
C⊗;



**** DRAFT **** DRAFT **** DRAFT **** DRAFT **** DRAFT **** DRAFT ***

STANFORD ARTIFICIAL INTELLIGENCE LABORATORY              May 22, 1976









                            Music Manual



                                 by


                                Tovar











ABSTRACT:

This document describes the compiler/interpeter, MUSCMP, used  in the
Stanford Computer  Music System.   It includes  a description  of the
language and its use.  MUSCMP  is the successor to MUS10,  written by
David W.  Poole and is  a descendant  of MUSIC V,  written by  Max W.
Mathews.
                            Music Manual


                  T A B L E   O F   C O N T E N T S



                               SECTION                           PAGE



1           Introduction

2           Declarations
             2-1     Identifiers .  .  .  .  .  .  .  .  .  .  .  . 3
             2-2     Variable Declaration .  .  .  .  .  .  .  .  . 3
             2-3     Array Declaration .  .  .  .  .  .  .  .  .  . 4
             2-4     Function declaration .  .  .  .  .  .  .  .  . 5

3           Expressions
             3-1     Function Call: .  .  .  .  .  .  .  .  .  .  . 8
             3-2     Unit Generator Call  .  .  .  .  .  .  .  .  . 8
             3-3     Array Subscripting   .  .  .  .  .  .  .  .  . 8

4           Statements
             4-1     Function Call: .  .  .  .  .  .  .  .  .  .   10
             4-2     Unit Generator Call  .  .  .  .  .  .  .  .   10
             4-3     Assignment Statement .  .  .  .  .  .  .  .   11
             4-4     WHILE Statement   .  .  .  .  .  .  .  .  .   11
             4-5     UNTIL Statement   .  .  .  .  .  .  .  .  .   11
             4-6     FOR Statement  .  .  .  .  .  .  .  .  .  .   12
             4-7     PRINT Statement   .  .  .  .  .  .  .  .  .   12
             4-8     Block .  .  .  .  .  .  .  .  .  .  .  .  .   13
             4-9     RETURN Statement  .  .  .  .  .  .  .  .  .   14
             4-10    DONE and EXIT Statements   .  .  .  .  .  .   14
                              ____

5           Extended Commands

6           Unit Generators
             6-1     Controlled Calling Rates   .  .  .  .  .  .   17
             6-2     VFMULT   .  .  .  .  .  .  .  .  .  .  .  .   17
             6-3     LINEN .  .  .  .  .  .  .  .  .  .  .  .  .   18
             6-4     VALUE .  .  .  .  .  .  .  .  .  .  .  .  .   18
             6-5     The OSCIL family of Unit Generators .  .  .   19
             6-6     The ZOSCIL Family of Unit Generators   .  .   20
             6-7     The RAND Family of Unit Generators  .  .  .   21

7           Built-in Functions
             7-1     SYNTH .  .  .  .  .  .  .  .  .  .  .  .  .   22
             7-2     SEG   .  .  .  .  .  .  .  .  .  .  .  .  .   22
             7-3     SEE   .  .  .  .  .  .  .  .  .  .  .  .  .   23

                                Page 
                            Music Manual


             7-4     SETCLOCK .  .  .  .  .  .  .  .  .  .  .  .   23
             7-5     PRINT .  .  .  .  .  .  .  .  .  .  .  .  .   23
             7-6     RDNUM .  .  .  .  .  .  .  .  .  .  .  .  .   24
             7-7     RAND  .  .  .  .  .  .  .  .  .  .  .  .  .   24
             7-8     INT   .  .  .  .  .  .  .  .  .  .  .  .  .   24
             7-9     FORTRAN Functions .  .  .  .  .  .  .  .  .   25

8           Computing sound
             8-1     PLAY Block  .  .  .  .  .  .  .  .  .  .  .   26
             8-2     Instrument call   .  .  .  .  .  .  .  .  .   27
             8-3     FINISH statement  .  .  .  .  .  .  .  .  .   29

9           Outputting the sound
             9-1     Short segments directly from MUSCMP .  .  .   30
             9-2     Longer segments using MUSCMP to write
                              a sound file   .  .  .  .  .  .  .   30
             9-3     Production runs   .  .  .  .  .  .  .  .  .   30

Appendix A  Syntax   .  .  .  .  .  .  .  .  .  .  .  .  .  .  .   32

Appendix B  Reserved Words .  .  .  .  .  .  .  .  .  .  .  .  .   35

Appendix C  Error Messages.   .  .  .  .  .  .  .  .  .  .  .  .   36

Appendix D  Changes since MUS10  .  .  .  .  .  .  .  .  .  .  .   43
             D-1     Changes to the Music Compiler (MUSCMP) .  .   43
             D-2     TAPNEW and CONNEW .  .  .  .  .  .  .  .  .   44
             D-3     Changes to UDPLAY .  .  .  .  .  .  .  .  .   44





















                               Page i
Music Manual


                              Section 1
                              _______ _

                            Introduction
                            ____________




The music compiler features a subset of ALGOL with special operations
directed toward music synthesis.  There are three modes  the compiler
can be in.  It can be in  COMPILE mode, where  instrument definitions
are accepted and compiled. It can be in PLAY mode, where it accepts a
note list and invokes these instruments to generate a sound waveform.
If  you  are  not  in  either  COMPILE  or  PLAY  mode,  you  are  in
interpretive mode, where  any ALGOL statements given  get interpreted
on the spot.


































                               Page 2
Music Manual


                              Section 2
                              _______ _

                            Declarations
                            ____________






2-1. Identifiers
     ___________


<identifier>            ::= <letter>{<alphanumeric>}
<alphanumeric>          ::= <letter>|<number>
<letter>                ::= A|B|C|...Z|_|$|#
<digit>                 ::= 0|1|2|...9


An identifier always  begins with a letter  and may be  followed with
any number of  letters or digits.   There are three  characters which
are treated as letters, $, # and _.  Lower case letters are converted
                        _  _     _
to upper case.  Certain  identifiers have special meanings  which may
not be used as names for variables, functions, arrays or instruments.
There  are  two kinds,  P  and U  variables,  which are  of  the form
P<number> and U<number> (see below) and reserved words like  ARRAY or
_             _                                              _____
BEGIN.  A list of reserved words is contained in Section 2.
_____



2-2. Variable Declaration
     ________ ___________


<variable declaration>  ::= VARIABLE <identifier>{,<identifier>};


All  variables must  be declared  before they  are used.   A variable
declaration consists of the reserved word VARIABLE followed by a list
of identifiers to  be declared as  variables.  All variables  must be
declared before they are used.

If variables are  to be used during  R-Time (see Section ,  they must
be declared as R-Time variable by preceding each variable name with a
slash in their declaration.

There are certain  variables, P1,P2,P3,..Pn and  U1,U2,U3,...Un which
have special meanings. Pn is the nth element of the P_Array, which is
the  list  of  parameters  to  an  instrument.  Within  an instrument


                               Page 3
Music Manual                                             Declarations


definition, Un is  the output of the  nth unit generator  within that
instrument definition.

All variables are stored  in floating point representation,  with two
exceptions.  One exception is in function definitions, where the data
types STRING  and INTEGER  are also  allowed, for  compatability with
external FORTRAN callable subroutines.  The second exceptions  are P-
variables, which do  not have a  specific type associated  with them.
This  means they  can  be used  as  variables, arrays,  and  so forth
without regard to type, hence  one must be careful using them  as one
can easily  make the mistake  of using a  number instead of  an array
with most unpredicatable results  (usually causes an ILL MEM  REF, or
                                                     ___ ___  ___
illegal memory reference).

Example:

VARIABLE A,B,/C,D,/RT;  COMMENT Declares A,B,D to be I-Time variables
                                Declares C,RT to be R-Time variables;



2-3. Array Declaration
     _____ ___________


<array declaration>  ::= ARRAY <array decl. list>
<array decl. list>   ::= <variable>[(<constant>)]
                            {,<array decl. list>}|
                         <variable>(<constant>)

All arrays must be declared  before they are used and  allows contain
numbers  in  floating  point  representation.   An  array declaration
consists of the reserved word ARRAY followed by a list  consisting of
the identifier followed by  the array size in  parenthesis, separated
by commas.  If  there are several arrays  of the same size,  the size
may be omitted on  all but the last  array of that size.   Arrays are
currently restricted to single subscripts.  Arrays within  blocks are
not  dynamically allocated(1);  they are  allocated at  compile time,
hence  they must  be a  fixed size.   Take note  that arrays  are not
initialized and may contain practically anything.

Example:

ARRAY F1,F2,F3(512),BAZ(2000);  COMMENT Declares F1, F2, F3 to be
                                arrays of length 512, BAZ to be an
                                array of length 2000;

_______________________
(1) Dynamic allocation will probably be implemented in the future.

                               Page 4
Music Manual                                             Declarations


Note: Array subscripts  always start with 0  and thus have  a maximum
subscript of one less than  the size of the array.  Thus,  F3[511] is
                                                           _______
the last element of the array F3 defined in the example.  See  Page 8
                              __
for details on referencing elements of an array.



2-4. Function declaration
     ________ ___________


<function declaration>  ::= FUNCTION <identifier>(<formal list>)
                                <function tail>|
                            EXTERNAL FUNCTION <identifier>
                                (<formal list>)
<formal list>           ::= <formal declaration>{,<formal list>}
<formal declaration>    ::= ARRAY <identifier> |
                            INTEGER <identifier>|
                            STRING <identifier> |
                            <identifier>
<function tail>         ::= ; <block> | = <expression>


A  function declaration  defines a  function in  MUSCMP.   A function
takes from 0 to 2n arguments, which may be variables,  arrays, string
constants or expressions and returns a value, which is a real number.
Functions are executed at  either I-time or R-time, depending  on the
arguments at the time they are called (see Page ).

The function declaration includes a list of formal  parameters, which
take  on  the values  of  their respective  real  arguments  when the
function is called.  The formal parameters are local  variables, that
is they are known only  within the function which they  are declared.
Outside  that  function,   they  are not  defined  or  may  have some
different definition.
Functions are always called  by reference(1), which means that  if an
assignment  is done  to one  of the  formal parameters,  the argument
itself will be modified.  Such assignments are  strongly discouraged,
since if the function is  called with a constant as an  argument, the
constant's value will change, which usually has disastorous results!

There are three  forms of function  declaration.  In the  first form,
the value of the function is the value of the expression to the right
of the the '='.   For example, the following function  calculates the
cube of a number.


_______________________
(1) This is the FORTRAN IV standard calling sequence on the PDP-10.

                               Page 5
Music Manual                                             Declarations



FUNCTION CUBE(X) = X * X * X;

PRINT CUBE(2);
8.


The second form is used for more complex functions.  Its value is the
expression part  of the  last RETURN  statement executed  within that
                              ______
function,  as  there may  be  more  than one  RETURN  statement  in a
                                              ______
function.  For example,   the following function returns  the maximum
amplitude of an waveform contained in an array.

FUNCTION AMPLITUDE(ARRAY M);
  BEGIN VARIABLE I,MAX;
    MAX←0;                  COMMENT Initialize maximum amplitude;
    FOR I ← 0 STEP 1 UNTIL LENGTH(M)
      DO IF ABS(M[I])>MAX THEN MAX←ABS(M[I]);
                            COMMENT Compare each element with
                                current maximum;
    RETURN MAX;             COMMENT The value of the function is
                                the maximum amplitude found;
    END;

The third form  is used for functions  written in FORTRAN  or machine
code.  It defines the argument list which the function expects to see
and fetchs the address from DDT's symbol table.  This means  that you
must to  use the same  name for  the function as  was written  in the
program or  MUSCMP will not  find its address!   The following  is an
example of this form of declaration.

EXTERNAL FUNCTION SQRT(X);

WARNING:  The syntax for  formal declaration will be changed  soon to
conform to ALGOL.














                               Page 6
Music Manual


                              Section 3
                              _______ _

                             Expressions
                             ___________




<expression>    ::= <simple expr><relop><simple expr>|<simple expr>
<simple expr>   ::= <term>|<term><addop><simple expr>
<term>          ::= <factor>|<factor><mulop><term>
<factor>        ::= <primary>
<primary>       ::= -<primary>|(<expression>)|<function call>|
                    <unit generator call>|<variable>←<expression>|
                    <variable>|<array ref>|<constant>
<array ref>     ::= <array name>[<expression>]
<relop>         ::= <|=|>|α≤|≠|≥
<addop>         ::= +|-
<mulop>         ::= *|/


Expressions are like algebraic formulae with certain changes required
so that they may  be typed on a  keyboard.  For example, '*`  is used
instead of 'x` and '/`  has been used to indicate division.   The use
of parenthesis is similar, but the following:

                3+4_5
                ___ _
                 72

should be  written as (3+4*5)/(7*2),  not 3+4*5/7*2.  When  in doubt,
                      _____________       _________
put in the extra parenthesis.  In mathematical notation, there  is an
implied  multiplication   frequently  used   which  must   be  stated
explicitly in MUSCMP,  therefore 2x+3 should be written as  2*X+3. It
                                                            _____
is  also  necessary  to  expiicately  parenthesis  the  arguments  to
functions which would not  be required in mathematical  notation, for
example, sin x should be written as SIN(X).
                                    ______

Relational operators, (as in x >  4) are defined to evaluate to  0 if
false and 1 if true.  One should use care with the operators  '=' and
'≠' as  floating point  arithmetic is  not exact(1)  discussion.  For
example:
PRINT 3/5+2/5 = 1;
0



_______________________
(1) See Knuth, The  Art of Computer Programming, Section  4.2.2 (Vol.
               ___  ___ __ ________ ___________
II) if you really want to know about this.

                               Page 7
Music Manual                                              Expressions


3-1. Function Call:
     ________ _____


<function call> ::= <function>(<parameter list>)
<parameter list>::= <parameter>,<parameter list>|<parameter>
<parameter>     ::= <expression>|<array>|<string constant>


A function call consists of  the function name followed by a  list of
parameters  separated by  commas  and enclosed  by  parenthesis.  The
effect is  to call  the function  (or subroutine)  with that  list of
parameters.  If the function is  not defined to return a  value, such
as a FORTRAN subroutine, the  value of the function is  undefined and
may be almost anything. For additional information on  functions, see
Page 5.  For descriptions of  the built-in functions  available,  see
Page 22.

Example:

PRINT SQRT(2);

1.414213



3-2. Unit Generator Call
     ____ _________ ____


A unit  generator is a  special kind of  function, as it  may contain
both at I-time and  R-time code and requires  special initialization,
Hence a unit generator call is only legal within an instrument.  Note
that a unit generator call within an expression can not be refered to
by Un.   Only unit generators  used as statements  are counted  for U
   _                                                                _
symbols.  See Section 6.



3-3. Array Subscripting
     _____ ____________


<array ref>     ::= <array name>[<expression>]


One can reference  particular elements of  an array by  following the
array name with the  index in square brackets(1). Thus,  F1[5] refers
                                                         _____

_______________________
(1) Parentheses are also acceptable here.

                               Page 8
Music Manual                                              Expressions


to element number 5 in the array F1.  Since arrays are always contain
                                 __
floating point  numbers, the construction  F1[5] represents  a single
                                           _____
floating point number and can be used like a variable.

It is important  to note that array  start with element number  0 and
thus if an array  F1 is of size n,  the last element of the  array is
                  __
F1[n-1].  For  example, the  following loads an  array, F1,  with one
___                                                     __
cycle of a sine wave:

ARRAY F1(512);
BEGIN VARIABLE I;
  FOR I←0 STEP 1 UNTIL 512-1
    DO F1[I]←SIN(I/512);
  END;


The index,  also known as  the subscript, is  check for  being within
range,  with   one  important   exception.   In   instruments,  array
references done at R-Time  are not check for efficiency  reasons.  If
an array reference is out of bounds, i.e. less than 0 or greater than
or equal to the array size, a diagnostic is printed.  For example:

I←512;
PRINT F1[I];

Subscript of out bounds for array F1, subscript = 512
??


It should  be noted  that since  number is  stored in  floating point
representation, it must be converted to an integer before referencing
the  array  element.   This conversion  is  accomplished  by  the INT
                                                                  ___
function  (see  Page  24)  and  is  NOT  the  same  as  rounding.  If
multiplication or  division is  done on  floating point  numbers, one
often gets something like 4.99999 instead of 5.0 as a result and when
this is used as a index, it will give the element number 4 instead of
5 as one might naively expect.












                               Page 9
Music Manual


                              Section 4
                              _______ _

                             Statements
                             __________



<statement>     ::= <function call>|<unit generator call>|
                    <WHILE statement>|<UNTIL statement>|
                    <FOR statement>|<conditional statement>|
                    <PRINT statement>|<assignment statement>|
                    <RETURN statement>|EXIT|DONE|
                    <block>



4-1. Function Call:
     ________ _____

<function call> ::= <function>(<parameter list>)
<parameter list>::= <parameter>,<parameter list>|<parameter>
<parameter>     ::= <expression>|<array>|<string constant>


A function call consists of  the function name followed by a  list of
parameters  separated by  commas  and enclosed  by  parenthesis.  The
effect is  to call  the function  (or subroutine)  with that  list of
parameters.  If the function returns a value, that value is lost.

Example:

SYNTH(F1);              COMMENT Call the function SYNTH with F1
                                as an argument;



4-2. Unit Generator Call
     ____ _________ ____

<unit generator call> ::= <unit generator>(<parameter list>)|
                <unit generator>[<expression>](<parameter list>)


A unit  generator is a  special kind of  function, as it  may contain
both at I-time and  R-time code and requires  special initialization,
Hence a unit generator call  is only legal within an  instrument. The
value of nth unit generator in an instrument can be refered to by Un.
                                                                  _
Only unit generators used as statements are counted for U symbols, if
                                                        _
a unit generator is used  with an expression it is not  counted.  See
Section 6.


                               Page 10
Music Manual                                               Statements


4-3. Assignment Statement
     __________ _________


<assignment statement> ::= <variable>←<expression>

This statement assigns the value of the expression to the variable to
the left of  the `←'  Caution: Assignment  to formal parameters  of a
function can have unexpected results;  see Page 5.

Example:

I←123;          COMMENT Set the value of the variable 'I` to 123;



4-4. WHILE Statement
     _____ _________

<WHILE statement> ::= WHILE <conditional> DO <statement>

A WHILE statement consists of the reserved word WHILE, an expression,
                                                _____
called  the  condition  followed  by  the  reserved  word  DO  and  a
                                                           __
statement.  So long  as the  condition is  true, i.e.  not  zero, the
statement will  be repeated  indefinitely.  Generally,  the statement
affects  part   of  the  condition   and  the   statement  eventually
terminates.

Example:

I←1; WHILE I<1000 DO PRINT(I←2*I);

2. 4. 8. 16. 32. 64. 128. 256. 512. 1024.



4-5. UNTIL Statement
     _____ _________


<UNTIL Statement> ::= DO <statement> UNTIL <conditional>

An  UNTIL  statement  is  like an  WHILE  statement  except  that the
statement is executed before  the condition and loop  terminates when
the  condition is  true.   It consists  of  the reserved  word  DO, a
                                                                __
statement followed by the reserved word UNTIL and an  expression, the
                                        _____
condition.





                               Page 11
Music Manual                                               Statements



Example:

I←10; DO PRINT(I←I-1) UNTIL I≤0;

9. 8. 7. 6. 5. 4. 3. 2. 1. 0



4-6. FOR Statement
     ___ _________


<FOR statement> ::= FOR <variable>←<expression> STEP <expression> 
                      UNTIL <expression> DO <statement>

This performs the statement for each value of the variable, beginning
with the expression immediately following the `←' in steps defined by
the second expression until it is greater than the  third expression.
The value  of the variable  will always be  the last value  which was
less than the third  expression.  If the first expression  is greater
than the third expression,  the statement will be  skipped altogether
and the variable unchanged.

Example:

FOR I←0 STEP 2 UNTIL 20 PRINT(I);

0 2. 4. 6. 8. 10. 12. 14. 16. 18. 20.



4-7. PRINT Statement
     _____ _________


<PRINT statement> ::= PRINT <print list>
<print list>      ::= <expression>,<print list>|<expression>|
                      <string constant>,<print list>|
                      <string constant>

This  types each  number or  string in  the print  list.  Numbers are
printed  in free  field format  with a  trailing space.   Strings are
printed  without a  leading  or trailing  space and  may  include any
character.  To enter a double quote, precede it with `≡' and to enter
                                                      _
`≡', put in two consecutive `≡'s.
 _                           _





                               Page 12
Music Manual                                               Statements



Example:

PRINT "SQRT(2) = ",SQRT(2);

SQRT(2) = 1.41423



4-8. Block
     _____


<block> ::= BEGIN <declaration list>;<statement list>
<declaration list> ::= <declaration>;<declaration list>|<declaration>
<statement list> ::= <statement>;<statement list>|END

A Block  is a  list of  statements, brackets  by the  reserved words,
BEGIN and  END and  separated by  the semicolons.   Anything declared
within a block is not known outside that block, but anything which is
declared outside a block may be referenced within that block provided
that it has not  been redefined.  Thus variables names  within blocks
maybe chosen without being concerned with name conflicts.

Example:

VARIABLE X; X←123; PRINT X;

123.

BEGIN VARIABLE X,Y;  X←456; Y←789;  PRINT X,Y;  END;

456. 789.

PRINT X;

123.

PRINT Y;

ERROR:  UNDEFINED IDENTIFIER    Line = 7 /1
PRINT Y;
       ↑
??






                               Page 13
Music Manual                                               Statements


4-9. RETURN Statement
     ______ _________

<RETURN statement> ::= RETURN <expression>

A RETURN statement is only valid within a function definition.  It is
  ______
used to terminate execution of a function and to return as  the value
of that  function, the expression  immediately following  the RETURN.
                                                              ______
There may be more than one RETURN statement in a given function.  See
                           ______
Page 6) for more information and an example.



4-10. DONE and EXIT Statements
      ____ ___ ____


A DONE statement is only valid within a FOR, WHILE, or UNTIL loop and
  ____                                  ___  _____     _____
serves provide an alternative means of terminating execution  of that
loop.  There may be more than one DONE statement in a given loop.  If
                                  ____
two loops are nested, the DONE only finishs from the innermost loop.
                          ____

An EXIT statement  provides for early  termination of a  block.  Like
   ____
the DONE statement, it only exits the innermost block.
    ____

DONE statements can appear  in blocks and EXIT statements  can appear
____                                      ____
in loops.  In such cases, both the block and the loop are exited.

The following example illustrates several uses of EXIT and DONE

COMMENT Print the first 100 prime numbers;

VARIABLE N,I;

PRINT 2;                        COMMENT Only even prime;
FOR N←3 STEP 2 UNTIL 100 DO     COMMENT Skip the rest of the evens;
  BEGIN
    FOR I←3 STEP 2 UNTIL N DO   COMMENT Try each factor;
      IF N = I*INT(N/I)         COMMENT If it divides evenly, stop;
          THEN EXIT             COMMENT (Exits block and continues
                                        outer FOR);
        ELSE IF N/I<I           COMMENT Don't bother past its square;
          THEN DONE;            COMMENT root. (Exits inner FOR);
    PRINT N;                    COMMENT We found one;
    END;                        COMMENT (of FOR loop);






                               Page 14
Music Manual


                              Section 5
                              _______ _

                          Extended Commands
                          ________ ________




These commands may be entered at the top level by preceding them with
an <alt mode> (which is echoed as $).
                                  _

Exit:                        <alt mode>EXIT
____

Return to Monitor.

Play:                        <alt mode>P <integer>
____

Plays the music buffered in  core the specified number of  times.  If
no argument is given, one is assumed.

Save:                        <alt mode>SAVE
____

Saves the music buffered in  core on a disk file.  At  Stanford, this
is in 12 bit format.

Print:                       <altmode>PRINT <expression>;
_____

Prints the value of the expression. It used to be an extended command
and is now generalized as an ordinary statement.  See Print Statement
on Page 12.

Reduce Core size:            <alt mode>EXCISE
______ ____ ____

Reduces to the minimum core required.

Space:                       <alt mode>SPACE
_____

Prints the total  space available followed  by the core  buffer space
and the number of seconds of sound which may be produced.

DDT:                         <alt mode>DDT
___

Starts up RAID or DDT. [Not usually loaded in system version  but may
be in other core images.]

Printing the Symbol Table:   <alt mode><declarator> LIST
________ ___ ______ _____

This list  the contents of  the symbol table.  Please note  that this


                               Page 15
Music Manual                                        Extended Commands


does not include symbols in inner blocks.  The following types may be
listed:

        VARIABLE
        FUNCTION
        ARRAY
        INSTRUMENT
        UNIT_GENERATOR









































                               Page 16
Music Manual


                              Section 6
                              _______ _

                           Unit Generators
                           ____ __________




Consider producing the  sound of a simple  sine wave.  If one  had to
call the sine subroutine for  each sample, it would take a  long time
to  compute a  second  of sound  even  at the  lowest  sampling rate.
Therefore, instead of calculating  the function for every  sample, an
array is  filled with  the values  of the  function.  Then,  for each
sample, the value is read out of the appropriate entry in  the array,
instead of calculating it.   Of course, for many kinds  of functions,
the value will not be as exact, but it is usually adequate for use in
music.  There are unit generators which do interpolation,  instead of
a simple array lookup, and these will produce accurate  enough values
for most critical cases.



6-1. Controlled Calling Rates
     __________ _______ _____


In  many  cases,  a  function  does  not  change  rapidly  with time.
Therefore to save computer time, it would be desirable not to have to
call the unit  generator for every sample.   This, which is  called a
controlled  calling  rate,  is  expressed  by  placing   a  bracketed
expression immediately  following the unit  generator name in  a unit
generator call.

Example:

        OSCIL[10](P4,10*MAG/P2,F1);

Calls the unit generator OSCIL every tenth sample, and uses the same
value for the other nine samples.




6-2. VFMULT
     ______


Argument list:

        1 - Amplitude
        2 - Subscript

                               Page 17
Music Manual                                          Unit Generators


        3 - Array

VFMULT multiplies the first  argument times the element of  the array
described by the  second argument. If  the second argument  is getter
than the array length, it is reduced by that array length until it is
within the size of the array.



6-3. LINEN
     _____


Argument list:

        1 - Amplitude
        2 - Rise time
        3 - Decay time
        4 - Total time
        5 - Array
        6 - Initial point in array

This function uses a 384 word array in three sections, to generate an
envelope  function with  separate  rise time,  intermediate  time and
decay  time.  The  rise time  and decay  time are  a function  of the
second argument, third argument and the total time.  Their  values in
seconds may be calculated according to the following formula.

To obtain a rise time of .1 seconds and a decay time of .4 seconds,

LINEN(P4,.1,.4,P2,F1,TMP←0);


CAUTION: The  initial point in  array must be  a variable  and should
usually be zero. If it is  a constant, you will clobber the  value of
that constant with most unpredicable results.



6-4. VALUE
     _____


Argument list:

        1 - Expression

VALUE is a special  unit generator which returns its  first parameter
as  its value.   Its  sole reason  for  existent is  to  allow R-time
expressions to be evaluated with a controlled calling rate.

                               Page 18
Music Manual                                          Unit Generators



Example:

VALUE[100](RV←A*SIN(X));




6-5. The OSCIL family of Unit Generators
     ___ _____ ______ __ ____ __________


OSCIL is short for oscillator. An OSCIL outputs successive  values of
the function (or waveform) stored  in an array.  When it  reached the
end of that array, it `wraps around' and starts back at the beginning
of  the array.   The  rate at  which it  moves  down the  array  is a
parameter  called  the  increment,  measured  in  array  elements per
sample,  which  is equal  to  the frequency  times  the  array length
divided  by the  sample rate.  For convenience,  there is  a variable
called MAG which is set to 512/SRATE, 512 being the length  of arrays
       ___                 _________  ___
used here and SRATE being the sample rate.  Since most functions used
              _____
with OSCIL range  between -1 and 1,  there is a parameter  called the
amplitude, by  which the value  of the function  is multiplied  by to
produce the value of unit generator.
The typical order of arguments is:

        1 - Amplitude
        2 - Increment
        3 - Array

The following are the many kinds of OSCIL's:

OSCIL:
_____

OSCIL always starts at the beginning of the array when the instrument
is called and will produce  an error message if a  negative increment
is supplied.

NOSCIL:
______

NOSCIL  always  starts  at  the  beginning  of  the  array  when  the
instrument is called and will accept a negative argument.

COSCIL:
______

COSCIL starts wherever it left off the last time that  instrument was
called.  (If there are more than one COSCIL's in an  instrument, they
do not effect each other.)  COSCIL will accept a negative argument.


                               Page 19
Music Manual                                          Unit Generators


EXPEN:
_____

EXPEN always  starts at  the beginning  of the  array and  instead of
'wrapping around` when it reachs the end, it always returns  the same
value upon subsequent calls.

NOSCA:
_____
Argument list:

        1 - Initial index in array
        2 - Amplitude
        3 - Increment
        4 - Array

NOSCA is a special form of  NOSCIL which sets where it starts  in the
array to the value of the first argument.



6-6. The ZOSCIL Family of Unit Generators
     ___ ______ ______ __ ____ __________


The  ZOSCIL  family  interpolates  between  the  two   closest  array
elements, rather that doing a straight lookup.  If it reaches the end
of an  array, it will  interpolate between the  last element  and the
first element, which may produce unexpected (but  consistent) results
for discontinuous functions.
The typical paramenter list is:

        1 - Amplitude
        2 - Increment
        3 - Array

The following are the various kinds of ZOSCIL.

ZOSCIL:
______

ZOSCIL always starts at the beginning of the array and will  accept a
negative increment.

CZOSCIL:
_______

CZOSCIL interpolates between  the two closest array  elements, rather
that doing  a straight  lookup.  Like COSCIL,  it starts  wherever it
left off the last time the instrument was called. CZOSCIL will accept
negative increment.

ZEXPEN:
______

                               Page 20
Music Manual                                          Unit Generators


ZEXPEN is  like a  EXPEN except ZEXPEN  interpolates between  the two
closest array  elements, rather  that doing  a straight  lookup. Like
EXPEN, instead of 'wrapping around` when it reachs the end, it always
returns the same value upon subsequent calls.

ZOSCA:
_____
Argument list:

        1 - Initial point in array
        2 - Amplitude
        3 - Increment
        4 - Array

ZOSCA is a special form of  ZOSCIL which sets where it starts  in the
array to the value of the first argument.



6-7. The RAND Family of Unit Generators
     ___ ____ ______ __ ____ __________


There are  two random  number generators that  are available  as unit
generators.   These are  RANDH and  RANDI. Both  of these  generate a
pseudo-random number  (via the linear  congruential method)  every so
often. The first argument  to these unit generators is  the amplitude
(it will go to plus  and minus that number), and the  second argument
is the  frequency (times MAG,  of course).  RANDH  will get  a random
number and hold it for one period (the time of which is determined by
the second  argument), whereas RANDI  will interpolate  linearly from
this point to the next.
Argument list:

        1 - Amplitude
        2 - Increment















                               Page 21
Music Manual


                              Section 7
                              _______ _

                         Built-in Functions
                         ________ _________






7-1. SYNTH
     _____


This is a FORTRAN subroutine, usually loaded with the Compiler, which
allows arrays to be loaded with the sum and/or product of sine waves.
To use  SYNTH, you must  dimension an array  to the  appropriate size
(presently 512) and call it with SYNTH(<array name>). You should then
                                 ______            _
input four numbers:

    1) the harmonic (denoted by H),
    2) the amplitude (denoted by A),
    3) the phase angle in degrees (denoted by P), and
    4) a constant with is added to the amplitude (denoted by K).

If K is  greater than 100  then it will  multiply instead of  add the
sine wave described.  It is terminated by the single entry of 999 for
H.  If you are at a III display,  after the four parameters,  the new
state of the array will be displayed.



7-2. SEG
     ___


Like SYNTH, this  is a subroutine  usually loaded with  the Compiler.
It allows  arrays to  be defined as  line segments.   To use  is, you
first must dimension an array to the appropriate size (presently 512)
and  call the  function  with SEG(<array  name>).   If you  are  at a
                              ____             _
display, it will display the  array as you load it. It  expects input
of two  numbers, the amplitude  and the position  in the array,  on a
scale from  0 to  100.  It  is terminated by  the entry  of 100  as a
position.


There is a version  of SYNTH and SEG which  will save the array  on a
file  in a  form which  may be  read by  the MUSCMP.   This is  in an
external program called FUNC.  If  you really want to know  about it,
see Leland Smith for details.


                               Page 22
Music Manual                                       Built-in Functions


7-3. SEE
     ___


Argument list:

1 - Array to be displayed

This routine displays the content of an array. It is called  with the
array to be displayed as  an argument in the form  SEE(<array name>).
                                                   __________ ______
Type  0<return> when  you are  done looking  at the  display  and the
      _
display will be cleared.



7-4. SETCLOCK
     ________


No Arguments

SETCLOCK may  be used to  setup NCHNS, SRATE  (the clock  or sampling
                                _____  _____
rate), and MAG to their appropriate values. When called, it  asks for
           ___
the number of channels and clock rate. It then sets MAG to 512/SRATE.
                                                    ___    _________
Available clock rates are 12800 and 25600.  Clock rates less than 100
are multiplied by 1000 (i.e. 12.8 becomes 12800);



7-5. PRINT
     _____


Argument list:

        1 - Number to be printed

Prints an integer  or floating point  number.  It is  mostly obsolete
and is here for  the use in compatablity  (see Page 12).  For  use in
FORTRAN  programs,  there  is   a  function  called  PNUM   which  is
                                                     ____
approximately equivalent to  PRINT. FORTRAN I/O is  incompatable with
MUSCMP and  attempts to  use it  will result  in various  errors like
ILLEGAL UUO AT XXX The difference in names is because the  name PRINT
would conflict with FORTRAN.








                               Page 23
Music Manual                                       Built-in Functions





7-6. RDNUM
     _____


Argument list:

        1 - Variable to recieve number

Inputs a number  from the current  input device.  Returns  a floating
point number.  Callable from FORTRAN, as FORTRAN I/O  is incompatable
with MUSCMP.



7-7. RAND
     ____


Generates pseudo-random numbers between -1 and 1(1).



7-8. INT
     ___


Argument list:

        1 - Number

Returns the integer part, or to be more precise the  entier function.
For example:

INT(123.456)=123
INT(-123.45)=-124











_______________________
(1) Currently, RAND does not generate statistically random numbers.

                               Page 24
Music Manual                                       Built-in Functions





7-9. FORTRAN Functions
     _______ _________


The following functions are loaded from the FORTRAN Library:

        SQRT(X)            Square root
        _______

        SIN(X)             Sine in radians
        ______
        SIND(X)            Sine in degrees
        _______

        COS(X)             Cosine in radians
        ______
        COSD(X)            Cosine in degrees
        _______

        ALOG(X)            Natural logarithm
        _______
        ALOG10(X)          Logarithm base 10
        _________

        ABS(X)             Absolute value
        ______

                            x
        EXP(X)             e
        ______


























                               Page 25
Music Manual


                              Section 8
                              _______ _

                           Computing sound
                           _________ _____






8-1. PLAY Block
     ____ _____

<play block>      ::= PLAY; <play list> |
                      PLAY <filespec>; <play list>
<play list>       ::= <instrument call>;<play list>|
                      <statement>;<play list>|
                      FINISH
<instrument call> ::= <instrument><parameter list>
<filespec>        ::= <filename><switches>|
                      <filename>
<switches>        ::= <switch><swiches>|<switch>
<switch>          ::= /BYTESIZE=<number>|
                      /SOUND


The play list specifies  when instruments are started, how  long they
are to  run, and what  paramenters they are  called with.   It starts
with PLAY  followed by  an optional output  file specification  as to
     ____
where  the output  is to  be directed.  If no  file  specification is
given, PLAY must be followed with a semicolon. MUSCMP knows about the
       ____
following devices at Stanford:

        DAC:  Digital-to-Analog converter
        ____
        DSK:  Disk file
        ____
        MTAn:     Magnetic tape (`magtape')
        _____
        UDP:  [Old format] user disk pack.(1)
        ____


If no  device is  specified, DSK:  is assumed  With the  exception of
                             ____
DAC:,  the default  is 18  bits  with the  last sample  in  each file
____
containing the maximum amplitude seen so far.  Magtape is  written in
a special format as  magtape does not ordinarily contain  a directory



_______________________
(1)  One could  write on  new  format UDP  by also  putting  the file
containing the play  list on the UDP  and giving the  moniter command
ASSIGN UDP1 DSK just before inputing the play list.
______ ____ ___

                               Page 26
Music Manual                                          Computing sound


or other indicates on the contents of that tape.(2) Unless  the sound
is fairly short,  it will be  broken up into  a number of  files with
progressively  increasing extensions.   For example,  if  you specify
FOO.0 as the output file, MUSCMP will write FOO.0, FOO.1, FOO.2, etc.
_____                                       _____  _____  _____
Whenever it finishes a file,  it also writes itself out on  your disk
area as XXX.SAV, where  XXX is the name  of your input file.   If the
        _______
system crashes or  you decide you want  to go home, you  can continue
the computation later  by saying RUN  XXX.SAV.  This even  applies to
                                 ___  _______
magtape,  although you  will have  to mount  it on  the  same logical
drive(1) and it may take awhile to find where it left off.

If a digital-to-analog converter is specified, you maybe  specify the
number of seconds to be  buffered in core memory by using  a floating
point number in place of the  file name which must have at  least one
digit preceding and following  the period.  For example,  PLAY DA:1.0
                                                          ____ ______
specifies  a  buffer for  one  second  of sound.   If  more  sound is
generated that specified  by the core buffer,  it will be put  out in
several discontinuous segments.



8-2. Instrument call
     __________ ____


The rest of a PLAY block consists of instrument calls  or statements.
A statement  is as described  in Section 10.   An instrument  call is
much like a function call.  It consists of the name of an instrument,
followed by a list  of parameter (or arguments).  When  an instrument
is called, the paramenters  are placed in corresponding  Pn variables
                                                         _
and  the  initialization  code  of  the  instrument  is  called.  The
initialization  code  saves   the  Pn  variables  and   preforms  any
                                   _
computations  which only  involve  I-time variables  (see  Section ).
The  rest  of the  instrument  code  is not  run  until  a subsequent
instrument call is read and  initialized which does not start  at the
same time, or  a FINISH statement is  seen.  Then each  instrument is
run, one  sample at a  time, until the  next instrument is  to begin.
Then more instrument calls are read until the next one is found which
begins at  a lster  time, and the  cycle is  repeated until  a FINISH
statement is seen and all instruments are finished.  As an instrument
finishs, it  is removed from  the list of  instruments to be  run for
each sample.
_______________________
(27) If you need to know the exact format, see Section 

(1) You  can get  around this restriction  using the  ASSIGN command.
                                                      ______
Suppose you need MTA0 but only MTA1 is available.  Say to the system,
ASSIGN  MTA1 MTA0  and any  program refering  to MTA0  will  get MTA1
______  ____ ____
instead.

                               Page 27
Music Manual                                          Computing sound


Example:

The following generates  1 second of a  440 Hz sine wave  followed by
1/2  second of  a 660Hz  sine  wave and  outputs it  directly  to the
Digital-to-analog converter

COMMENT Fill array with sine wave;
ARRAY SINETABLE[511];
FOR I←0 STEP 1 UNTIL 511 DO SINETABLE[I]←SIN(2*PI/512);

INSTRUMENT SINE;
  COMMENT Generate simple sine wave.  P3 = Amplitude, P4 = frequency;
  OUTA←OUTA+OSCIL(P4,P3*MAG,SINETABLE);
  END;

COMMENT Now, generate the sound;
PLAY DA:1.5;
  SIMP 0, 1, 1000, 440;
  SIMP 1, 1/2, 1000, 660;
  FINISH;


Arguments to instruments may be either numbers or array, and one must
be careful to use the right type, as the compiler does not  check for
you!  If you give an array  instead of a number, you will  merely get
meaningless results.  However, if you give a number when an  array is
expected, you will most likely get a message from the moniter such as
?
ERROR IN JOB 31
ILL MEM REF AT USER 7601
↑C
.

The first two parameters in an instrument call have a special meaning
to  MUSCMP.  Traditionally the  second  two parameters  are  are also
special meaning, but could be used for any purpose.  The meanings are
as follows:

P1     Begin time  Time  at  which  the  instrument  is  started,  in
__
                   seconds.
P2     Duration    Length of time instrument will be run, in seconds.
__
P3     Frequency   Typically  fundemental   frequence  or   pitch  of
__
                   instrument [optional].
P4     Amplitude   Typically maximum sample  to be generated  by this
__
                   instrument [optional].

Usually, arguments to instruments which are arrays usually  appear at


                               Page 28
Music Manual                                          Computing sound


the end of an instrument call.  P3 and P4 are sometimes interchanged,
                                __     __
especially in FM instruments, so amplitude is P4 and frequency is P3.
                                              __                  __

Because of the way instruments are compiled, it is not  possible call
the same instrument twice  during same time period.  This  is because
it has only one set of temperary variables.



8-3. FINISH statement
     ______ _________


A  FINISH  statement  terminates   a  PLAY  block.   It   causes  all
   ______
instruments to run  to completion and the  output file to  be closed.
It also asks you if you want to delete the temperary file which saved
the state of your computation on long runs.

































                               Page 29
Music Manual


                              Section 9
                              _______ _

                        Outputting the sound
                        __________ ___ _____






9-1. Short segments directly from MUSCMP
     _____ ________ ________ ____ ______


For simple tests of a  few seconds, it is probably easiest  to output
the sound directly from MUSCMP.  One does this by naming the digital-
to-analog converter in the PLAY statement, such as PLAY DAC:1.0; (for
                                                   ____ ________
details, see section on PLAY statement on page Page 27).



9-2. Longer segments using MUSCMP to write a sound file
     ______ ________ _____ ______ __ _____ _ _____ ____


For longer tests, one can write  a disk file which later send  to the
digital-to-analog converter without  change.  One does this  by using
something  like  PLAY DSK:TEST.SND/BYTESIZE=12/SOUND,  where  DSK: is
                 ____ ______________________________          ____
optional.  (Admittedly, this is  rather verbose and will  probably be
shorted soon.) When the computation is finished, one then runs one of
the disk playing programs:

DAC       Copies directly from DSK:  or [new] UDP: to  [new]DAC:.  It
                               ____           ____          ____
          accepts  12 bit  or 18  bit files  and handles  1, 2,  or 4
          channels at 12.8 KHz  or 25.6 KHz.  Program attempts  to be
          self-documenting  and will  ask  you about  clock  rate and
          number of channels if it can't figure it out itself.

(At the time of writing, conversion from the old DAC: to the new DAC:
was in progress.  Documentation on other programs should be available
shortly.)



9-3. Production runs
     __________ ____


For production runs or long tests which need to be  interruptable, it
is best to write a series of files instead of one large one.  If just
a file name  is given to  MUSCMP with no  switches this is  what will


                               Page 30
Music Manual                                     Outputting the sound


happen.  In addition,  this file is written  in 18 bit format  with a
special code at the end  representing the maximum sample seen so far.
These files are not suitable for playing directly, but do retain more
accuracy  than  the more  common  12  bit sound  files  and  could be
converted to some other byte  size at another time.  This  dates back
to when we only had a  12 bit DAC and wanted to  preserve significant
                              ___
computations in a  form that could be  utilized by high  accuracy DAC
                                                                  ___
which we might obtain in the  future.  In order to send the  sound to
the DAC:, you must convert  the many files into one long  file.  This
    ____
is done  by a special  program called NMUSIO.   It takes one  or more
                                      ______
sequences of files and combines them into one large file which can be
written  on  either  the  DSK: or  an  old  format  UDP:.   Its basic
                          ____                      ____
operation  is as  follows.   It first  asks  for a  description  of a
sequence  of files.   This consists  of the  name of  the  first file
followed by a '-'  and then the name of  the last file.  It  looks to
see  how  they  are  different and  increments  the  first  file name
accordingly  to  access  the second  and  subsequent  files  until it
matches the  last filee.  It  then asks where  the output  should go.
This should be a single file (with an optional device specification).
NMUSIO then converts from 18 bit to 12 bit and does  optional scaling
(if for example, the samples in the 18 bit would not fit in a  12 bit
word).  When it finishes that sequence of files, it asks if  you want
to aadd another sequence by saying "More input?".  If you answer 'y',
it  will then  expect another  sequence specification  which  it will
convert and  asks you  again if  you have  another sequence.   If you
answer 'n', it will  close your files and  exit. You then run  one of
the programs described in the previous section to hear what it sounds
like.





















                               Page 31
Music Manual


                                  A
                                  _

                               Syntax
                               ______




Note:  {<foo>} means there may be from 0 to ∞ occurances of <foo>.

<block>                 ::= BEGIN <declaration list>;<statement list>
<declaration list>      ::= <declaration>;<declaration list>|
                            <declaration>
<statement list>        ::= <statement>;<statement list>|END
<statement>             ::= <function call>|<unit generator call>|
                            <assignment statement>|<block>
                            <WHILE statement>|<UNTIL statement>|
                            <FOR statement>|<conditional statement>|
                            <PRINT statement>
<function call>         ::= <function>(<parameter list>)
<unit generator call>   ::= <unit generator>(<parameter list>)|
                     <unit generator>[<expression>](<parameter list>)
<parameter list>        ::= <parameter>,<parameter list>|<parameter>
<parameter>             ::= <expression>|<array>|<string constant>
<FOR statement>         ::= FOR <variable>←<expression> STEP
                            <expression> UNTIL <expression> DO
                            <statement>
<PRINT statement>       ::= PRINT <print list>
<print list>            ::= <expression>,<print list>|<expression>|
                            <string constant>,<print list>|
                            <string constant>
<WHILE statement>       ::= WHILE <conditional> DO <statement>
<UNTIL statement>       ::= DO <statement> UNTIL <conditional>
<assignment statement>  ::= <variable>←<expression>
<play block>            ::= PLAY; <play list> |
                            PLAY <filespec>; <play list>
<instrument call>       ::= <instrument><parameter list>
<extended commands>     ::= EXIT|P <integer>|PRINT <expression>;|
                            RESET|FREEZE|SPACE|DDT|
                            <declarator> LIST
<declarator>            ::= VARIABLE|ARRAY|FUNCTION|INSTRUMENT|
                            UNIT_GENERATOR
<declaration>           ::= <variable declaration>|
                            <array declaration>
<variable declaration>  ::= VARIABLE <var. dec. list>
<var. dec. list>        ::= <identifier>,<var. dec. list>|
                            /<identifier>,<var. dec. list>|
                            <identifier>|/<identifier>
<array declaration>     ::= ARRAY <array decl. list>

                               Page 32
Music Manual                                                   Syntax


<array decl. list>      ::= <array decl. group>,<array decl. list>|
                            <array decl. group>
<array decl. group>     ::= <variable>,<array decl. group>|
                            <variable>(<constant>)
<expression>            ::= <term>|<term><addop><expression>
<term>                  ::= <factor>|<factor><mulop><term>
<factor>                ::= <primary>
<primary>               ::= -<primary>|(<expression>)|<variable>|
                            <function call>|<unit generator call>|
                            <array name>(<expression>)|<constant>
                            <variable>←<expression>
<addop>                 ::= +|-
<mulop>                 ::= *|/
<variable>              ::= <letter><var tail>|<letter>
<var tail>              ::= <alphanumeric><var tail>|<alphanumeric>
<alphanumeric>          ::= <letter>|<number>
<letter>                ::= A|B|C|...Z|_|$|#
<digit>                 ::= 0|1|2|...9































                               Page 33
Music Manual


                                  B
                                  _

                           Reserved Words
                           ________ _____



ARRAY             EXIT              INTEGER           RPRINT
BEGIN             EXTERNAL          LENGTH            STEP
COMMENT           FINISH            LIST              STRING
COMPILE           FOR               PI                THEN
DONE              FUNCTION          PLAY              UNIT_GENERATOR
DO                I_ONLY            PRINT             UNTIL
ELSE              IF                R_PRINT           VARIABLE
END               INSTRUMENT        RETURN            WHILE



































                               Page 35
Music Manual


                                  C
                                  _

                           Error Messages.
                           _____ _________




A simple statement inside a 'COMPILE' section just wastes space!
It will never be executed.

AD error
Error detected while outputing to the DAC.

Attempt to reference unit generator output at R-Time
At I-time, the output of a unit generator is undefined.

C O M P I L E R   E R R O R  ! ! ! Get TOVAR or save this core image 
Something  unexpected has  happened  which would  probably  should be
looked at as it is most likely a bug.

Can't INIT AD
Digital to Analog Converter is probably in use.

Can't INIT DSK!
An unlikely situation.

Can't INIT TTY!
An unlikely situation.

Can't INIT mag tape
Someone else is probably using it.

Can't OPEN output file

Can't delete .SAV file
Perhaps someone is referencing it.

Can't expand core!
Could get enough core.  You lose.

Can't expand core

Can't have an R-time statement controlled by an I-time conditional
The  DO  ...  UNTIL   statement  will  never  terminate   under  such
circumstances.

Can't re-INIT output device.
Someone else it probably using it.

                               Page 36
Music Manual                                          Error Messages.


Can't reduce core!
Shouldn't happen.

Can't setup buffers for output
This error is probably due to some change to I/O in system.

DONE statement illegal here

DRYROT IN MAG. TAPE ROUTINE

Dangling ELSE or extraneous ';' in IF...THEN...ELSE statement
The statement following the 'THEN' in a IF...THEN...ELSE statement is
terminated by the ELSE and should not have a semicolon after it.

Declarations should be made at start of block
You may continue from this error.

Dimension should be a number
Dynamic arrays are not implimented.

ERROR IN READING THE BITMAP/DIRECTORY

ERROR IN SETTING UP BUFFER RINGS

ERROR IN WRITING BITMAP!

ERROR IN WRITING TAPE DIRECTORY!
The tape files were  written correctly, however, the  directory could
not be written out properly.  Use tape fixing program on this one.

EXIT statement illegal outside of block

EXPRESSION TOO COMPLEX, MAY BE A COMPILER BUG

Expected to find a '←' here
The compiler assumed you meant as assignment statement.

External functions only, please
The compiler does not know about anything else being external.

FORWARD REF. TO UNIT GENERATOR
You have most likely referenced the output of a unit  generator which
have  not  been defined  yet.  [If there  are  no Un  symbols  in the
expression, it may be a compiler bug.]

ILLEGAL DEBUGFLAG SETTING

ILLEGAL FILE NAME

                               Page 37
Music Manual                                          Error Messages.


ILLEGAL FORMAL PARAMETER

IMPROPER ARRAY PARAMETER

IMPROPER STRING PARAMETER

INIT failed for that device

INPUT ERROR

INTEGERS PRESENTLY ALLOWED ONLY FOR EXTERNAL FUNCTIONS, SORRY

Illegal byte size, ignored

Illegal character in number
Not a digit or decimal point.

Illegal character
A character was found in file which has no meaning to the compiler.

Illegal declaration
You  may not  make a  declaration of  type UNIT_GENERATOR,  STRING or
INTEGER.

Illegal primary

Illegal primary
Should be a number, variable, array or function call.

It appears that your tape directory has been garbaged.
Read error or some sort of inconsistancy on directory.

MAG TAPE ERROR???!?

MAG. TAPE ERROR

Missing '(' after array
You are probably trying to use a array as a variable.  Arrays must be
subscripted.

Missing '(' in array declaration

Missing '(' in function call

Missing ')' after array subscript

Missing ')' in array declaration


                               Page 38
Music Manual                                          Error Messages.


Missing ')' in expression
Unbalanced parentheses or missing operator in expression.

Missing ')' in function definition

Missing ')' or too many parameters in function call

Missing ';' or '=' in function definition

Missing ';'

Missing ';'
Statements should be terminated with a semicolon

Missing '=' in BYTESIZE

Missing 'BEGIN' in function definition

Missing 'DO' in FOR

Missing 'END'

Missing 'STEP' in FOR

Missing 'THEN'
'THEN' Missing in IF...THEN...ELSE Statement.

Missing 'UNTIL' in FOR

Missing 'UNTIL'
UNTIL missing from DO ... UNTIL statement or extraneous ';`.

Missing ']' in unit generator call

Missing '←' in FOR

Missing DO in WHILE statement

Missing END
FINISH statement giving inside a block.

Missing External function
Either  an  external  function  was  not  loaded  or  its   name  was
misspelled.

Missing IDENTIFIER

Multiply defined symboi

                               Page 39
Music Manual                                          Error Messages.


Multiply dimensional array not implimented, sorry

Multiply dimensioned arrays not implemented
You may also have confused an array name with a function name.

NEGATIVE INC. TO OSCIL
OSCIL is not defined to go accept a negative increment however if you
continue from  this error it  will treat this  increment as  a NOSCIL
does.

NOT ALLOWED IN 'PLAY' SECTION

Negative increment to LINEN
LINEN  is  undefined for  negative  increments.  The  results  may be
unpredicatable.

Negative increment to ZEXPEN
ZEXPEN is undefined for  negative increments however if  you contiune
it will treat it like a ZOSCIL.

Never heard of that switch

OUTn too big, clipped
Sample  just computed  was  too big  to  represent in  the  byte size
currently being used for  output. This usually is indicative  of some
problem in an instrument.

Output error?
Error detected while writing out sample buffer

PARITY ERROR ON MAG. TAPE

R-Time condition for I-Time Statement in WHILE statement
No R-Time  code was  generated after an  R-Time conditional.    It is
most likely that this will result in an infinite loop!

R-Time conditional for I-time IF-THEN-ELSE statement
No R-time code was  generated after an R-Time  conditional. Therefore
the IF-THEN statement acts as  if the condition were always  true for
the 'THEN' clause and always false for the 'ELSE' clause!

RETURN statement illegal outside of function definition
Only functions may return a value.  Use EXIT to leave a block.

SETPR2 failed! Therefore, can't do output to mag tape.
The program peeks  at the monitor  to find out  what the mag  tape is
doing.  The UUO which permits this failed.


                               Page 40
Music Manual                                          Error Messages.


STRING REQUIRED HERE

SWAP failed

Simple variable required here
FOR loops expect a simple variable, i.e. not an array.

Storage full!

String too long or missing "
Strings have a limited length.

Subscript out of bounds at compile time.
You have a subscript  expression which evaluates to a  constant which
is either too large or too small.

Tape full and no checkpoint to restart from.

This feature can not be used on DEC systems yet. Sorry.
There are  some things you  can do  at Stanford that  you can  not do
elsewhere.

This isn't FORTRASH. Use a '←' assignment next time
However '=' will be accepted under protest.

Too few arguments in function call

Too many END statements

Too many parameters in function call

UDP in use or assignned to another job

UNDEFINED IDENTIFIER

UNDEFINED IDENTIFIER
An identifier was used before it was declared.

Undefined IDENTIFIER

Unexpected symbol beginning a statement
It will be ignored and attempt to continue compilation.

Unimplimented operation
AND and OR are not implimented.

Unit Generator call illegal outside of instrument definition


                               Page 41
Music Manual                                          Error Messages.


Unit generators  are only to  be used inside  of instruments  as they
require special initialization at I-time.

Unit generator call illegal outside of instrument definition
Unit generators  are only to  be used inside  of instruments  as they
require special initialization at I-time.

Use of two relational operator is illegal here

You are calling an instrument which is already running!
Since the code generated for instruments is non-reentrant, you should
not  call  it with  overlapping  time periods  as  this  will produce
unpredicable  results.  Instead  you  should make  a copy  of  with a
different name  (and different  variable names  if they  are declared
outside that instrument).

You have the wrong pack mounted on the UDP
The password for the UDP scratch pack was not correct.































                               Page 42
Music Manual


                                  D
                                  _

                         Changes since MUS10
                         _______ _____ _____




Most of the problems which  caused the message ILL MEM REF  have been
eliminated.   If  come  across  any problems  or  have  any  needs or
suggestions,  Please bring  them  to my  attention by  saying  to the
Monitor:

.MAIL TVR


The MAIL program will explain itself.



D-1. Changes to the Music Compiler (MUSCMP)
     _______ __ ___ _____ ________ ________


The  sample  output routines  have  been rewritten  to  eliminate the
BIGBIT  kludge.  The  intermediate files  whose extensions  have been
MUSAA.DMD are  now in the  form: <file name>.<integer>,  for example:
TEST.0,  TEST.1, TEST.2,...  Now more  than one  set  of intermediate
files may be  on the disk at  one time an any  set may be  deleted by
saying DEL <file name>.*, for example DEL TEST.*. The format has also
been changed, since it is  no longer done with FORTRAN.   Therefore a
new  conversion  program has  also  been written  to  replace CONNEW,
called  NMUSIO. GARPLY  is still  used to  play from  the  disk.  For
details, see Page 26.

The error printout routines now contain an option to continue,  or to
edit, to retry, or to debug with DDT.

Core is  obtained automatically, whenever  possible.  It  still loses
under certain circumstances.

Play now prints the run time used in computing the samples.

When the Compiler asks for  an input file, it is no  longer necessary
to precede a file name with DSK:.  If just a return is typed, TTY: is
assumed.

The Compiler will accept files editted by TVED or E.



                               Page 43
Music Manual                                      Changes since MUS10


When inputting  from the TTY,  SYNTH and SEG  will display  the array
being filled.

MUSCMP  should generate  slightly better  code and  evaluate constant
expressions during compilation.

Array elements may  be individually referenced.  This  allows complex
waveforms  to   be  described   by  arbitrarily   complex  mathematic
expression, instead  of the previous  restrictions to  combination of
sine waves or approximation by line segments.

There is a  new set of statements  and block structure  added.  These
statements include  IF,  WHILE,  UNTIL and  FOR statements.   A print
statement  has  been  added  which  allows  literal  strings  so that
messages may be printed as well as numbers, which are now  printed in
floating point notation.  The literal strings  may also be  passed to
functions. In order to  use certain routines in the  FORTRAN Library,
the data type INTEGER has been added but is currently limited  to the
external functions  until type  conversion code can  be added  to the
compiler.

Functions may now be blocks as well as expressions.

To make debugging the  compiler easier, a special debugging  mode has
been added.



D-2. TAPNEW and CONNEW
     ______ ___ ______


TAPNEW and CONNEW  will not work with  MUSCMP, please read  about new
scheme on 30.   Note that tapes written  in the old format  should be
read with the old programs.



D-3. Changes to UDPLAY
     _______ __ ______


UDPLAY now detects the previously mysterious premature end  of sound.
Also,  a  problem  in  the old  version  caused  it  to  do excessive
computation which often caused  the lossage described above  has been
corrected. It  also new  checks the validity  of your  responses, and
will restart if you type altmode or backspace.




                               Page 44
                            Music Manual


                              I N D E X

                  (References are to Page numbers)


ABS                            25   local variables                 5
Absolute value                 25   Logarithm                      25
argument                        5
Array Subscripting              8   NOSCA                          20
Assignment statement        5, 11   NOSCIL                         19

BEGIN                          13   OSCIL                          19
BIGBIT                         43
Block                          13   P_Array                         3
                                    Plays                          15
called by reference             5   PNUM                           23
Controlled Calling Rates       17   PRINT                  12, 15, 23
COSCIL                         19
Cosine                         25   RAID                           15
CZOSCIL                        20   RAND                           24
                                    RDNUM                          24
DDT                            15   Reserved Words                 35
Declaration            3, 4, 5, 6   RETURN                      6, 14
DMD                            43
DONE                           14   SEE                            23
                                    SEG                            22
END                            13   SETCLOCK                       23
EXCISE                         15   Sine                           25
EXIT                           15   SPACE                          15
EXP                            25   Square root                    25
EXPEN                          20   Statement      10, 11, 12, 13, 14
Exponent                       26   subroutine                  8, 10
Expressions                     7   subscript                       9
Extended Commands          15, 16   Syntax                     32, 33
External                        6   SYNTH                          22

FOR                            12   UDPLAY                         44
formal parameter                5   Unit Generator                 10
FORTRAN I/O                    23   Unit Generators17, 18, 19, 20, 21
Function Call               8, 10   UNTIL                          11

identifier                      3   VALUE                          18
increment                      19   VFMULT                         17
index                           9
INT                            24   WHILE                          11

LINEN                          18   ZEXPEN                         20
LIST                           15   ZOSCA                          21

                               Page 45
                            Music Manual







ZOSCIL                         20











































                               Page 46